<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/global/global-head.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>吉车惠后台管理系统</title>
	<%@include file="/global/global-other.jsp" %>
<script type="text/javascript">
	var $bn_oilStaion_worker_list = new Object();
	var $bn_oilStaion_worker_list_Datagrid;
	var $bn_oilStaion_worker_list_toolbar = [{
		text:'<i class="fa fa-search " aria-hidden="true"></i>查询',
		handler:function(){
			$bn_oilStaion_worker_list.reload();
		}
	},
		{
			text:'<i class="fa fa-retweet" aria-hidden="true"></i>查看详情',
			handler:function(){
				$bn_oilStaion_worker_list.saveInit();
			}
		},
		{
			text:'<i class="fa fa-chain" aria-hidden="true"></i>用户冻结',
			handler:function(){
				$bn_oilStaion_worker_list.isFreeze();
			}
		},
		{
			text:'<i class="fa fa-unlink" aria-hidden="true"></i>解除冻结',
			handler:function(){
				$bn_oilStaion_worker_list.notFreeze();
			}
		}
	];
	$(function(){
		$bn_oilStaion_worker_list_Datagrid = $('#bn_oilStaionDatagrid').datagrid({
			filterBtnIconCls:'icon-filter',
			queryParams: {
//				filter_EQ_delete_status: 0
			},
			pageSize : 20,
			remoteFilter:true
		});
		$bn_oilStaion_worker_list_Datagrid.datagrid('enableFilter', [

			{field:'phone',type:'text'},
			{field:'name',type:'text'},
			{field:'nickName',type:'text'},
			{field:'sex',type:'text'},
			{field:'firstPayMarkName',type:'text'},
			{
				field:'ages',
				type:'combobox',
				options:{
					valueField: 'code',
					textField: 'name',
					url:'${ctx}/tcode/all/method?method=getCacheCdAgeGroup'
				},
				op:['equal']
			},
			{field:'provinceCode',type:'text'},
			{field:'cityCode',type:'text'},
			{field:'trade',type:'text'},
			{field:'certification',type:'text'},
			{
				field:'freezeStatus',
				type:'combobox',
				options:{
					valueField: 'code',
					textField: 'name',
					data: [{
						code: '0',
						name: '未冻结'
					},{
						code: '1',
						name: '已冻结'
					}
					]
				},
				op:['equal']
			},
			{
				field:'lockStatus',
				type:'combobox',
				options:{
					valueField: 'code',
					textField: 'name',
					data: [{
						code: '0',
						name: '未锁定'
					},{
						code: '1',
						name: '已锁定'
					}
					]
				},
				op:['equal']
			},
			{
				field:'firstPayMark',
				type:'combobox',
				options:{
					valueField: 'code',
					textField: 'name',
					data: [{
						code: '0',
						name: '否'
					},{
						code: '1',
						name: '是'
					}
					]
				},
				op:['equal']
			},
			{field:'registerAt',type:'text'},
			{field:'lastLoginAt',type:'text'},
			{field:'lastSigninAt',type:'text'},
			{field:'invitationCode',type:'text'}
		]);

	});


	$bn_oilStaion_worker_list.test=function(a){

	}

	$bn_oilStaion_worker_list.reload = function(){
		$("#bn_oilStaionDatagrid").datagrid('reload');
	};

	var viewDialog = null;
	$bn_oilStaion_worker_list.saveInit = function(){
		var row = $bn_oilStaion_worker_list_Datagrid.datagrid('getSelected');
		if(row==null){
			$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
		}
		$('#saveinit').html("");
		viewDialog = parent.$.dialog({
			title: '<i class="fa fa-windows"></i><span class="dialog-title">详细信息<span>',
			href: '${ctx}/an/app/detailed?_m=init&id='+row.appUserId+'&r='+Math.random(),
			width: 1100,
			height: 640,
			modal: true,
			onClose : function() {
				$(this).dialog('destroy');
			},
			buttons: [{
				text:'<i class="fa fa-reply" aria-hidden="true"></i>&nbsp;返 回',
				width:'70px',
				handler: function(){
					viewDialog.dialog('destroy');
				}
			}]
		});
	}

	//冻结用户
	$bn_oilStaion_worker_list.isFreeze = function (){
		var row = $bn_oilStaion_worker_list_Datagrid.datagrid('getSelected');
		if(row==null){
			parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
		}else{
			var freezeStatus = row.freezeStatus;
			if(freezeStatus == '1'){
				$.messager.alert("提示",errMsg("您选择的用户已经冻结，无法重复冻结！"),"error");
				return;
			}
			parent.$.messager.confirm('提示','是否要冻结用户手机为：【'+row.phone+'】这条记录？',function(flag){
				if (flag){
					$.post('${ctx}/an/app/update?_m=setFreezeStatus', {id : row.appUserId,freezeStatus:1}, function(json) {
						if(statusMsg(json)){
							parent.$.messager.alert("提示","冻结用户成功！","info",function(){
								$bn_oilStaion_worker_list_Datagrid.datagrid('reload');
							});
						}
					}, "JSON");
				}
			});
		}
	}
	//解除冻结
	$bn_oilStaion_worker_list.notFreeze = function (){
		var row = $bn_oilStaion_worker_list_Datagrid.datagrid('getSelected');
		if(row==null){
			parent.$.messager.alert("提示",errMsg("请选择一行数据！"),"error");
		}else{
			var freezeStatus = row.freezeStatus;
			if(freezeStatus == '0'){
				$.messager.alert("提示",errMsg("您选择的用户未冻结，无法解除冻结！"),"error");
				return;
			}
			parent.$.messager.confirm('提示','是否要解除冻结用户手机为：【'+row.phone+'】这条记录？',function(flag){
				if (flag){
					$.post('${ctx}/an/app/update?_m=setFreezeStatus', {id : row.appUserId,freezeStatus:0}, function(json) {
						if(statusMsg(json)){
							parent.$.messager.alert("提示","解除冻结成功！","info",function(){
								$bn_oilStaion_worker_list_Datagrid.datagrid('reload');
							});
						}
					}, "JSON");
				}
			});
		}
	}

</script>
	</head>
<body>
<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
<table id="bn_oilStaionDatagrid"  style="width:100%;height: 100%"
	   data-options="border:false,rownumbers:true,autoRowHeight:false,singleSelect:true,pagination:true,sortName:'registerAt',sortOrder:'desc',toolbar:$bn_oilStaion_worker_list_toolbar,rowStyler: function(index,row){return {style:'height:30px'};},url:'${ctx}/an/app/search?_m=load',method:'post'">
	<thead>
		<tr>
			<th data-options="field:'phone',width:120,align:'center'">手机号</th>
			<th data-options="field:'name',width:120,align:'center'">姓名</th>
			<th data-options="field:'nickName',width:100,align:'center'">昵称</th>
			<th data-options="field:'sex',width:80,align:'center',formatter:
                    function(value,row,index){
                        if(row.sex=='1'){
                            return '男';
                        }else if(row.sex=='2'){
                            return '女';
                        }else{
                            return '未知';
                        	}
                        }">性别</th>
			<th data-options="field:'ages',width:100,align:'center',formatter:function(value,row,index){return row.agesName;}">年龄段</th>
			<th data-options="field:'provinceCode',width:100,align:'center'">省份</th>
			<th data-options="field:'cityCode',width:100,align:'center',formatter:function(value,row,index){return row.cityName;}">城市</th>
			<th data-options="field:'trade',width:120,align:'center'">行业</th>
			<th data-options="field:'certification',width:120,align:'center'">实名认证</th>
			<th data-options="field:'freezeStatus',width:100,align:'center',formatter:
                    function(value,row,index){
                        if(row.freezeStatus=='0'){
                            return '未冻结';
                        }else if(row.freezeStatus=='1'){
                            return '已冻结';
                            }
						}">冻结状态</th>
			<th data-options="field:'lockStatus',width:100,align:'center',formatter:
                    function(value,row,index){
                        if(row.lockStatus=='0'){
                            return '未锁定';
                        }else if(row.lockStatus=='1'){
                            return '已锁定';
                            }
                        }">锁定状态</th>
			<th data-options="field:'firstPayMark',width:80,align:'center',formatter:
                    function(value,row,index){
                        if(row.firstPayMark=='0'){
                            return '否';
                        }else if(row.firstPayMark=='1'){
                            return '是';
                            }
                        }">是否首冲</th>
			<th data-options="field:'registerAt',width:140,align:'center'">注册时间</th>
			<th data-options="field:'lastLoginAt',width:140,align:'center'">最后一次登录时间</th>
			<th data-options="field:'lastSigninAt',width:140,align:'center'">最后一次签到时间</th>
			<th data-options="field:'invitationCode',width:80,align:'center'">邀请码</th>
		</tr>
	</thead>
</table>
</div>
	</div>
</body>
</html>